//
//  TBCPermissionViewController.m
//  待定
//
//  Created by BoyaLee on 15/11/10.
//  Copyright © 2015年 BoyaLee. All rights reserved.
//

#import "TBCPermissionViewController.h"
#import "TBCPermissionCell.h"

@interface TBCPermissionViewController () <UITableViewDataSource, UITableViewDelegate>

@property (strong, nonatomic) NSMutableArray *arrayTitle;

@end

@implementation TBCPermissionViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    [self initPermissionViews];
    [self initPermissionData];
    
    UIImage *image = [UIImage imageNamed:@"fanhui.png"];
    //取消渲染
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithImage:image style:UIBarButtonItemStylePlain target:self action:@selector(leftBarAction:)];
    
}

//自定义左侧按钮
-(void)leftBarAction:(UIBarButtonItem *)barItem
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)initPermissionViews {
    
    self.navigationController.navigationBar.translucent = NO;
    
    self.view.backgroundColor = [UIColor whiteColor];
    
    UITableView *permissionTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, WIDTH, HEIGHT - 64) style:UITableViewStylePlain];
    permissionTableView.delegate = self;
    permissionTableView.dataSource = self;
    [self.view addSubview:permissionTableView];
    
}

- (void)initPermissionData {
    
    self.arrayTitle = [NSMutableArray arrayWithCapacity:0];
    self.arrayTitle = [NSMutableArray arrayWithObjects:@"AFNetWorking",@"MBProgressHUD",@"MJRefresh",@"SDWebImage",@"StreamingKit", nil];
    
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
    
    NSString *title = self.arrayTitle[section];
    
    return title;
    
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    return 200;
    
}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    
    return self.arrayTitle.count;
    
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    
    return 1;
    
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    
    TBCPermissionCell *cell = [tableView dequeueReusableCellWithIdentifier:@"permissionCell"];
    
    if (!cell) {
        
        cell = [[TBCPermissionCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"permissionCell"];
        
    }
    
    cell.fileName = self.arrayTitle[indexPath.section];
    
    return cell;
    
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
